package com.byzk.p2p.admin.user.controller;

import java.io.UnsupportedEncodingException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.byzk.p2p.admin.base.controller.AdminBaseController;
import com.byzk.p2p.admin.base.util.PageInfo;
import com.byzk.p2p.admin.order.service.OrderService;
import com.byzk.p2p.admin.order.vo.TenderAutoVo;

@RequestMapping(value="/admin/user/autoTender")
@Controller
public class UserAutoTenderController extends AdminBaseController{
	@Autowired
	private OrderService orderService;
	
	/**
	 * 用户自动投标分页列表
	 * @param model 视图对象
	 * @param index 当前页数
	 * @param limit 每页显示条数
	 * @param username 用户名
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping(value="/listUserAutoTender")
	public String listUserAutoTender(Model model,
						   @RequestParam(value="index",required=false,defaultValue="1") int index,
						   @RequestParam(value="limit",required=false,defaultValue="10") int limit,
						   @RequestParam(value="username",required=false) String username)throws Exception{
		TenderAutoVo tenderAutoVo = new TenderAutoVo();
		tenderAutoVo.setIndex(index);
		tenderAutoVo.setLimit(limit);
		if (StringUtils.isNotBlank(username)) {
			username=java.net.URLDecoder.decode(username , "UTF-8");
			tenderAutoVo.setMatchUser(username);
			model.addAttribute("username", username);
		}
		PageInfo<TenderAutoVo> pageInfo=orderService.listAuto(tenderAutoVo);
		model.addAttribute("pageInfo", pageInfo);
		return ftl(Thread.currentThread().getStackTrace());
	}
}
